/**********************************************************************
 Name:  TestRouteMapControl
 Purpose:RouteMapControl 测试用例                                                          
-------                                                             
======================================================
History                                                            
-------                                                            
VERSION    AUTHOR                  DATE                 DETAIL                                
   1.0 -        huangxiaojiang       03/22/2011         Create  
***********************************************************************/
@isTest
private class TestRouteMapControl{
    static testMethod void test(){
        Profile p=[select  id from profile where  name='Sales Rep - Trade' limit 1];
        User u=new user(alias='hxj',email='xjhuang80ww7@isoftstone.com',lastName='testing'
               ,languageLocaleKey='zh_CN',localeSidkey='zh_CN' ,TimeZoneSidKey='Asia/Shanghai',EmailEncodingKey='UTF-8',
               profileId=p.id,userName='xjhuang123@isoftstone.com');
        
        System.runAs(u){
           
           //新建地区
          Place__c oPlace=new Place__c();
          oPlace.name='地区1';
          oPlace.CityType__c='Base City';
          oPlace.PlaceType__c='City';
          oPlace.CityCode__c='c001';
          insert oPlace;
          
          //新建店面
          Account oAcc=new   Account();
          oAcc.Name='店面1';
          oAcc.City__c=oPlace.id;
          oAcc.Channel__c='百货店';
          oAcc.Contact__c='aaa';
          oAcc.No_of_checkout__c=22;
          oAcc.ContactPhoneNumber__c='1234567456';
          oAcc.lat__c='26.008760201342253';
          oAcc.lon__c='104.5917953491211';
          insert oAcc;
          
          Account oAcc1=new   Account();
          oAcc1.Name='店面2';
          oAcc1.City__c=oPlace.id;
          oAcc1.Channel__c='百货店2';
          oAcc1.Contact__c='aaa1222';
          oAcc1.No_of_checkout__c=2211;
          oAcc1.ContactPhoneNumber__c='12345617456';
          oAcc1.lat__c='26.308760201342253';
          oAcc1.lon__c='114.5917953491211';
          insert oAcc1;
          
           //拜访计划       
           //今天
          Routing_Plan_And_Visit__c oRPAV=new  Routing_Plan_And_Visit__c();
          oRPAV.Visit_Date__c=date.today();
          insert oRPAV;
          
          //计划
          RoutingPlan__c oRP=new RoutingPlan__c();
          oRP.RoutingPlanAndVisit__c=oRPAV.Id;
          oRP.OutletName__c=oAcc.Id;
          oRP.StartDateTime__c=dateTime.now();
          oRP.EndDateTime__c=dateTime.now().addHours(1);
          insert oRP;
          
          RoutingPlan__c oRP1=new RoutingPlan__c();
          oRP1.RoutingPlanAndVisit__c=oRPAV.Id;
          oRP1.OutletName__c=oAcc1.Id;
          oRP1.StartDateTime__c=dateTime.now().addHours(2);
          oRP1.EndDateTime__c=dateTime.now().addHours(3);
          insert oRP1;
          
           //新建instoreVisit记录
            list<In_Store_Visit__c> lstISV=new  list<In_Store_Visit__c>();
            In_Store_Visit__c oISV1=new  In_Store_Visit__c();
            oISV1.RoutingPlanAndVisit__c=oRPAV.id;
            oISV1.Start_Time__c=dateTime.now();
            oISV1.End_Time__c=dateTime.now().addHours(1);
            oISV1.OutletName_del__c=oAcc.id;
            oISV1.RoutingPlanItem__c=oRP1.id;
            oISV1.lat__c='29.308760201342253';
            oISV1.lon__c='64.5917953491211';
            lstISV.add(oISV1);

             In_Store_Visit__c oISV2=new  In_Store_Visit__c();
            oISV2.RoutingPlanAndVisit__c=oRPAV.id;
            oISV2.Start_Time__c=dateTime.now().addHours(1);
            oISV2.End_Time__c=dateTime.now().addHours(2);
            oISV2.OutletName_del__c=oAcc1.id;
            oISV2.RoutingPlanItem__c=oRP.id;
            oISV2.lat__c='29.308760201342253';
            oISV2.lon__c='64.5917953491211';
            lstISV.add(oISV2);
            
            insert lstISV;
            
           
            ApexPages.StandardController pageControl=new ApexPages.StandardController(oRPAV);
            RouteMapControl rMCPage=new RouteMapControl(pageControl); 
            rMCPage.RPVId=oRPAV.id; 
            rMCPage.pageLoadAction();
        }
    }
}